const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const VueLoaderPlugin = require('vue-loader/lib/plugin')

module.exports = {
    mode: "development", // 开发模式
    entry: __dirname + '/src/main.js',
    output: {
        path: __dirname + '/dist',
        filename: 'bundle.js'
    },
    devServer: {
        contentBase: './src',
        historyApiFallback: false,
        inline: true,
        hot: true
    },
    module: {
        rules:[
            {
                test:/\.css$/,
                use: ['style-loader','css-loader']
            },
            {
                test:/\.(jpg|png|gif|woff|svg|eot|ttf)$/,
                loader: 'url-loader'
            },
            {
                test:/\.vue$/,
                loader: 'vue-loader'
            },
            {
                test:/\.less$/,
                use: ['style-loader','css-loader','less-loader']
            },
            {
                test:/\.{js|jsx}$/,
                use:{
                    loader:'babel-loader'
                },
                exclude:/node_modules/
            }
        ]
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: __dirname + '/src/index.html'
        }),
        new VueLoaderPlugin(),
        new webpack.HotModuleReplacementPlugin()
    ]
}